import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import './assets/css/global.css'

import axios from 'axios'

import qs from 'qs'

axios.defaults.baseURL = 'http://127.0.0.1:8081/'

// 添加请求拦截器
axios.interceptors.request.use(function (config) {
  if (config.method !== 'get') {
    config.data = qs.stringify(config.data)
  }
  config.headers['Content-Type'] = 'application/x-www-form-urlencoded'
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
}, function (error) {
  return Promise.reject(error)
})

Vue.prototype.$http = axios

Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
